{extend name="Teacher/nav"} {block name="title"}梦云智选课系统{/block} {block name="content"}
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <h3>当前开放抢课学期:{$currentSemester->name}</h3></div>
    </div>
    <div class="row">
        <div class="col-md-12" style="margin-bottom: 20px;"><span>当前位置:</span><span>{$currentSemester->name}-></span><span>第{$currentWeekorder}周-></span><span>{$currentClassroom->name}</span></div>
    </div>
    <div class="row ">
        <div class="col-md-12">
            <form action="{:url('takelessonInterface')}" method="get" class="form-inline">
                <div class="row">
                    <div class="col-md-12">
                        <input type="hidden" name="semester_id">
                    </div>
                    <div class="col-md-5">
                        <label>周次：</label>
                        <select class="form-control" name="weekorder">
                            {for start="$currentSemester->startweekorder" end="($currentSemester->endweekorder)+1" }
                            <option value="{$i}" {eq name="$i" value="$currentWeekorder" } selected="selected" {/eq}>第{$i}周</option>
                            {/for}
                        </select>
                    </div>
                    <div class="col-md-5">
                        <label>选择教室：</label>
                        <select class="form-control" name="classroom_id">
                            {volist name="allClassroom" id="classroom"}
                            <option value="{$classroom->id}" {eq name="$currentClassroom->id" value="$classroom->id" } selected="selected" {/eq}>{$classroom->name}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="col-md-2">
                        <button type="submit" class="btn btn-default">搜索</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="row">
        <!-- 表格 -->
        <div class="col-md-12">
            <!-- 显示信息表格 -->
            <!-- 表格 -->
            <table class="table table-hover table-bordered">
                <tr class="info">
                    <th class="textCenter">星期/节次</th>
                    <th class="firstTd">星期一</th>
                    <th class="firstTd">星期二</th>
                    <th class="firstTd">星期三</th>
                    <th class="firstTd">星期四</th>
                    <th class="firstTd">星期五</th>
                    <th class="firstTd">星期六</th>
                    <th class="firstTd">星期日</th>
                </tr>
                {volist name="secheduleList" id="sechedules" key="key"}
                <tr>
                    <td class="tableTd">第{$key}节</td>
                    {volist name="sechedules" id="sechedule"}
                    <td class="tableTd">
                        {eq name="sechedule->teacher_id" value="$null"}
                        <div>
                            <span>无课</span>
                            <br> {eq name="sechedule->isChangeLesson" value="1"}
                            <span>换课中</span> {else/}
                            <span class="glyphicon glyphicon-hand-right" aria-hidden="true"><a data-toggle="modal" data-target="#TakeLessons" data-whatever="{$sechedule->id}">抢课</a></span> {/eq}
                        </div>
                        {else/}
                        <span>教师:{$sechedule->teacher->name}</span>
                        <br>
                        <span>课程:{$sechedule->course->name}</span>
                        <br>
                        {volist name="Klasses" id="Klass"} {eq name="$sechedule->getKlassesIsChecked($Klass)" value="true"}<span>{$Klass->name}</span>{else/}{/eq} {/volist}
                        <br> {eq name="sechedule->isChangeLesson" value="1"}
                        <span style="border-bottom: 1px; text-decoration:underline;color: gray;">换课中</span> {else/} {eq name="$sechedule->teacher_id" value="$teacher->id"}
                        <div>
                            <span class="glyphicon glyphicon-circle-arrow-right" aria-hidden="true"></span>
                            <a data-toggle="modal" data-target="#ChangeLesson" data-whatever="{$sechedule->id}">换课</a>
                        </div>
                        {/eq} {/eq} {/eq}
                    </td>
                    {/volist}
                </tr>
                {/volist}
            </table>
        </div>
    </div>
</div>
<!--抢课的表单-->
<form action="{:url('takeLesson')}" method="post">
    <div class="modal fade" id="TakeLessons" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-body">
                    <div>
                        <input type="hidden" name="secheduleId" id="secheduleId">
                        <input type="hidden" name="teacherId" value="{$teacher->id}">
                    </div>
                    <span>请选择上课班级和课程：</span>
                    <div class="container">
                        {volist name="tcolleges" id="College"}
                        <label>{$College->name}:</label>
                    <div>
                     {volist name="tmajors" id="Major"}
                     <div {neq name="$Major->college_id" value="$College->id" } hidden="hidden" {/neq}>
                        <div>
                            {volist name="tgrades" id="Grade"}
                            <div {neq name="$Grade->major_id" value="$Major->id" } hidden="hidden" {/neq}>
                                <div class="container">
                                    {volist name="tklasses" id="Klass" key="key"}
                                    <div {neq name="$Klass->grade_id" value="$Grade->id" } hidden="hidden" {/neq}>
                                        <label> <input type="checkbox" value="{$Klass->id}" name="klassIds[{$key}]" >{$Klass->name}</label>
                                    </div>
                                    {/volist}
                                </div>
                            </div>
                            {/volist}
                        </div>
                    </div>
                    {/volist}
                    </div>
                   {/volist}
                  </div>
                    <hr/>
                <div class="container">
                    <label>课程名称:</label>
                    <br>
                    <div class="container">
                        <div class="row col-md-6">
                            {volist name="tcourses" id="Course" key="key"}
                            <div class="col-md-4">
                                <input type="radio" value="{$Course->id}" name="courseId" id="course{$key}">
                                <label for="course{$key}">{$Course->name}</label>
                            </div>
                            {/volist}
                        </div>
                    </div>
                    <br />
                </div>
                <div class="modal-footer">
                    <a type="button" class="btn btn-primary " data-toggle="modal" data-target="#addCourse" style="margin-right: 330px">
                        <span class="glyphicon glyphicon-plus"></span>
                        添加课程</a>
                    <button type="submit" class="btn btn-primary">
                        <span class="glyphicon glyphicon-ok" ></span>
                        保存</button>
                </div>
            </div>   
        </div>
    </div>
    </div>
</form>
<!--老师可以在本页面增加课程-->
<div class="modal fade" id="addCourse" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="padding-top: 10%">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form action="{:url('addCourse?isTakelesson=true')}" class="form-inline" method="post">
                <div class="modal-body">
                    <label>课程名称:</label>
                    <input name="newCourseName" placeholder="请输入要增加的课程名">
                    <input type="hidden" name="teacherId" value="{$teacher->id}" class="form-control">
                    <input name="fromInformation" value="0" hidden="hidden">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">确认</button>
                </div>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
$('#TakeLessons').on('show.bs.modal', function(event) {
    var button = $(event.relatedTarget);
    var recipient = button.data('whatever');
    var modal = $(this);
    modal.find('#secheduleId').val(recipient)
})
</script>
<!-- 换课表单 -->
<div class="modal fade" id="ChangeLesson" tabindex="-1" role="dialog" aria-labelledby="ChangeLesson">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="ChangeLesson">请选择要换到什么时间和教室</h4>
            </div>
            <div class="modal-body">
                <form action="{:url('changeLesson')}" method="post" class="form-inline">
                    <!-- 将要换课的id传给c层 -->
                    <div class="form-group">
                        <input type="hidden" class="form-control" id="id" name="id">
                    </div>
                    <!-- 选择目标周次 -->
                    <div class="form-group">
                        <label>周次</label>
                        <select class="form-control" name="weekorder">
                            {for start="$currentSemester->startweekorder" end="($currentSemester->endweekorder)+1" }
                            <option value="{$i}" {eq name="$i" value="$currentWeekorder" } selected="selected" {/eq}>第{$i}周</option>
                            {/for}
                        </select>
                    </div>
                    <!-- 选择目标星期 -->
                    <div class="form-group">
                        <label for="week">星期</label>
                        <select name="week" id="week" class="form-control">
                            <option value="1">星期一</option>
                            <option value="2">星期二</option>
                            <option value="3">星期三</option>
                            <option value="4">星期四</option>
                            <option value="5">星期五</option>
                            <option value="6">星期六</option>
                            <option value="7">星期日</option>
                        </select>
                    </div>
                    <!-- 选择目标节次 -->
                    <div class="form-group">
                        <label for="node">节次</label>
                        <select name="node" id="node" class="form-control">
                            <option value="1">第一节</option>
                            <option value="2">第二节</option>
                            <option value="3">第三节</option>
                            <option value="4">第四节</option>
                            <option value="5">第五节</option>
                        </select>
                    </div>
                    <!-- 选择目标教室 -->
                    <div class="form-group">
                        <label>选择教室</label>
                        <select class="form-control" name="classroom_id">
                            {volist name="allClassroom" id="classroom"}
                            <option value="{$classroom->id}" {eq name="$currentClassroom->id" value="$classroom->id" } selected="selected" {/eq}>{$classroom->name}</option>
                            {/volist}
                        </select>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="submit" class="btn btn-primary">确定</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
$('#ChangeLesson').on('show.bs.modal', function(event) {
    var button = $(event.relatedTarget)
    var recipient = button.data('whatever')
    var modal = $(this)
    modal.find('.modal-body input').val(recipient)
})
</script>
{/block}